package com.jeff.android.lab.database.room;

import com.jeff.android.lab.BaseFragment;
import com.jeff.android.lab.R;
import com.jeff.utils.ToastUtil;

import java.util.List;

import butterknife.OnClick;

/**
 * @author: dingfeng
 * @date: 2019-11-04
 * @since: 1.0.0
 **/
public class RoomFragment extends BaseFragment {

    @Override
    protected int getRootLayout() {
        return R.layout.db_fragment_room;
    }

    @Override
    protected void initData() {

    }

    @OnClick(R.id.btn_insert)
    public void insert() {
        User user = new User("Jack", 25);
        DbHelper.instance().getUserDao().insert(user);
    }

    @OnClick(R.id.btn_query)
    public void query() {
        List<User> users = DbHelper.instance().getUserDao().getAll();
        ToastUtil.show(mContext, "" + users.get(0).name);
    }


}
